package com.hunan.api.catv.action.album;

import com.hunan.api.catv.action.BaseAction;
import com.hunan.api.catv.common.Api;
import com.hunan.api.catv.entity.Result;
import com.hunan.api.catv.service.biz.cache.CacheBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(Api.album)
public class AlbumAction extends BaseAction {

    @Autowired
    CacheBiz cacheBiz;

    @GetMapping("/list")
    public Result list(Integer columnId, int pageNum, HttpServletRequest request) {
        return buildOK(cacheBiz.albumPage(columnId, pageNum, getPageSize(request)), "");
    }


    @GetMapping("/videoList")
    public Result videoList(Integer albumId) {
        return buildOK(cacheBiz.albumVideolist(albumId), "");
    }

    @GetMapping("/info")
    public Result info(Integer albumId) {
        if (ObjectUtils.isEmpty(albumId)) {
            return buildRequire("albumId require");
        }
        return buildOK(cacheBiz.albumSimpleInfo(albumId), "");
    }
}
